﻿@using Gx.Model.ViewModel;
@model LKWarehouseOutDto
@{
    ViewBag.Title = "编辑商品出库单";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script src="~/Js/Global.js?v=20240706"></script>
<script type="text/javascript">
    $(function () {
        InitCustomer();
        $('#sbIsByTon').switchbutton({ checked: @Html.Raw(Model.WarehouseOut.IsByTon ? "true" : "false") });
        $('#sbIsReview').switchbutton({ checked: @Html.Raw(Model.WarehouseOut.IsReview ? "true" : "false") });
        $('#CustomerId').combogrid('setValue', { Id: '@Model.WarehouseOut.CustomerId', CustomerName: '@Model.WarehouseOut.CustomerName' });
    });

    function addDom() {
        var customerId = $("#CustomerId").combobox('getValue');
        if (customerId == "") {
            Helper.Show("请选择客户");
            return;
        }
        $('#dlg').dialog('open').dialog('setTitle', '商品引导出库');
        $('#dg').datagrid('load', {
            CustomerId: customerId
        });
        initDom();
    }

    function delDom(domId) {
        $("#" + domId).remove();
        removecalculateWeight();
    }

    function addDom2() {
        var domId2 = $("#CostDomNum").val();
        $.post("/GoodsOrder/_AddLKWarehouseEntryCost", { domId: domId2 }, function (html) {
            $.messager.progress('close');
            $("#costgird").append(html);
            $.parser.parse($("#CostTr" + domId2));
            InitCostTypesCombogrid2(domId2, initCostType);
            InitChargingUnitCombobox(domId2);
            $("#CostDomNum").val(Number(domId2) + 1);

            initDom();
        });
    }

    function delDom2(id) {
        $("#CostTr" + id).remove();

        //domId2 = Number(domId2) - 1;
        removecalculateAmount();
    }

    var costdom = new Array();
    var detaildom = new Array();

    function initDom() {
        costdom.length = 0;
        detaildom.length = 0;
        $("input[type='hidden'][id^='CostDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, costdom) === -1) {
                costdom.push(d);
            }
        });
        $("input[type='hidden'][id^='DetailDomId']").each(function () {
            var d = $(this).val();
            if ($.inArray(d, detaildom) === -1) {
                detaildom.push(d);
            }
        });

    }


    function querycustomer2() {
        $("#CustomerId").combogrid("grid").datagrid("reload", { "Customer": $("#SelectCustomerText2").val() });
    }

    function selectEntryDetail() {
        var detail = $('#dg').datagrid('getSelected');
        if (detail == null) {
            Helper.Show("请选择商品");
            return;
        }
        var domId = $("#DomNum").val();
        $.post("/GoodsOrder/_AddLKWarehouseOutDetail", { domId: domId }, function (html) {
            $.messager.progress('close');
            $("#detailgird").append(html);
            $.parser.parse($("#" + domId));
            initOutDetail(domId, detail);
            $("#DomNum").val(Number(domId) + 1);
        });


        $('#dlg').dialog('close');
    }
    function initOutDetail(id, detail) {
        $("#GoodsNo" + id).textbox('setValue', detail.GoodsNo);
        $("#GoodsId" + id).val(detail.GoodsId);
        $("#GoodsName" + id).textbox('setValue', detail.GoodsName);
        $("#GoodsSpecId" + id).val(detail.GoodsSpecId);
        $("#GoodsSpecName" + id).textbox('setValue', detail.GoodsSpecName);
        $("#Weight" + id).numberbox('setValue', detail.Weight);
        $("#OutNumber" + id).numberbox('setValue', detail.Number);
        $("#PlateNumber" + id).numberbox('setValue', detail.PlateNumber);
        $("#Area" + id).numberbox('setValue', detail.Area);
        $("#TonWeight" + id).numberbox('setValue', detail.TonWeight);
        $("#InventoryNumber" + id).numberbox('setValue', detail.Number);
        $("#InventoryArea" + id).numberbox('setValue', detail.Area);
        $("#InventoryTonWeight" + id).numberbox('setValue', detail.TonWeight);
        $("#WareHouseId" + id).val(detail.WareHouseId);
        $("#WareHouseName" + id).textbox('setValue', detail.WareHouseName);
        $("#EntryTime" + id).datebox('setValue', detail.CreateTime);
        $("#ProductionDate" + id).datebox('setValue', detail.ProductionDate);
        $("#ExpirationDate" + id).datebox('setValue', detail.ExpirationDate);
        $("#ProducingArea" + id).textbox('setValue', detail.ProducingArea);
        $("#Remark" + id).textbox('setValue', detail.Remark);
    }

    function print() {
        var printUrl = "/GoodsOrder/LKWarehouseOutPrint?id=" + @Model.WarehouseOut.Id;
        window.open(printUrl, "_blank");
    }


    //计算总重量
    function calculateWeight() {
        initDom();
        var triggerControl = this;
        var value = $(triggerControl).numberbox('getValue');

        //获取triggerControl的id的最后一个字符
        var id = $(triggerControl).attr("id");
        var lastChar = id.substr(id.length - 1, 1);
        var number = $("#OutNumber" + lastChar).numberbox('getValue') * 1;
        var weight = $("#Weight" + lastChar).numberbox('getValue') * 1;
        var tonweight = (number * weight.toFixed(4)) / 1000;
        $("#TonWeight" + lastChar).numberbox('setValue', tonweight);

        var totalton = 0;
        var total = 0;
        detaildom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#OutNumber" + i).numberbox('getValue') * 1;
            var weights = $("#Weight" + i).numberbox('getValue') * 1;

            var tonweight = (numbers * weights.toFixed(4)) / 1000;
            totalton += tonweight;
            total += numbers;
        });
        $("#TotalTon").numberbox('setValue', totalton);
        $("#Total").numberbox('setValue', total);
    }

    function removecalculateWeight() {
        initDom();
        var totalton = 0;
        var total = 0;
        detaildom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#OutNumber" + i).numberbox('getValue') * 1;
            var weights = $("#Weight" + i).numberbox('getValue') * 1;

            var tonweight = (numbers * weights.toFixed(4)) / 1000;
            totalton += tonweight;
            total += numbers;
        });
        $("#TotalTon").numberbox('setValue', totalton);
        $("#Total").numberbox('setValue', total);
    }


    //计算金额
    function calculateAmount() {
        initDom();
        var triggerControl = this;
        var value = $(triggerControl).numberbox('getValue');

        //获取triggerControl的id的最后一个字符
        var id = $(triggerControl).attr("id");
        var lastChar = id.substr(id.length - 1, 1);
        var number = $("#CNumber" + lastChar).numberbox('getValue') * 1;
        var unitprice = $("#UnitPrice" + lastChar).numberbox('getValue') * 1;
        var amount = (number * unitprice).toFixed(2);
        $("#Amount" + lastChar).numberbox('setValue', amount);

        var totalAmount = 0.00;
        costdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#CNumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#UnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#Amount").numberbox('setValue', totalAmount);
    }

    function removecalculateAmount() {
        initDom();
        var totalAmount = 0.00;
        costdom.forEach(function (value, index) {
            var i = value;
            var numbers = $("#CNumber" + i).numberbox('getValue') * 1;
            var unitprices = $("#UnitPrice" + i).numberbox('getValue') * 1;

            var tonam = (numbers * unitprices).toFixed(2) * 1;
            totalAmount += tonam;
        });
        $("#Amount").numberbox('setValue', totalAmount);
    }

    function initCostType(row) {
        var id = row.did;
        $("#CostTypeId" + id).val(row.data.Id);//combobox('setValue', rowData.Id);
        $("#CostType" + id).combobox('setValue', row.data.CostTypeName);
        $("#ChargingUnit" + id).combobox('setValue', row.data.Unit);
        $("#UnitPrice" + id).numberbox('setValue', row.data.UnitPrice);
    }


    function editLKWarehouseOut() {
        var validate = $("#fm").form("validate")
        if (!validate) {
            return;
        }
        var data = {
            "Id": $("#Id").val(),
            "BillNo": $("#BillNo").textbox('getValue'),
            "OutTime": $("#OutTime").datebox('getValue'),
            "CustomerId": $("#CustomerId").combobox('getValue'),//$("#hidCustomerId").val(),
            "CustomerNo": $("#CustomerId").combobox('getText'),
            "CustomerName": $("#CustomerName").textbox('getValue'),
            "CarNumber": $("#CarNumber").textbox('getValue'),
            "TotalTon": $("#TotalTon").numberbox('getValue'),
            "Total": $("#Total").numberbox('getValue'),
            "Amount": $("#Amount").numberbox('getValue'),
            "IsByTon": $('#sbIsByTon').switchbutton('options').checked,
            "PorterNo": $("#PorterNo").textbox('getValue'),
            "IsReview": $('#sbIsReview').switchbutton('options').checked,
            "Remark": $("#Remark").val()
        };

        var isCheck = true;
        initDom();
        var detailList = new Array();
        detaildom.forEach(function (value, index) {
            var i = value;
            var Id = $("#DetailId" + i).val();
            var OutId = $("#OutId" + i).val();
            var GoodsNo = $("#GoodsNo" + i).textbox('getValue');
            var GoodsId = $("#GoodsId" + i).val();
            var GoodsSpecId = $("#GoodsSpecId" + i).val();
            var GoodsName = $("#GoodsName" + i).textbox('getValue');
            var GoodsSpecName = $("#GoodsSpecName" + i).textbox('getValue');
            var Weight = $("#Weight" + i).numberbox('getValue');
            var OutNumber = $("#OutNumber" + i).numberbox('getValue');
            var PlateNumber = $("#PlateNumber" + i).numberbox('getValue');
            var Area = $("#Area" + i).numberbox('getValue');
            var TonWeight = $("#TonWeight" + i).numberbox('getValue');
            var InventoryNumber = $("#InventoryNumber" + i).numberbox('getValue');
            var InventoryArea = $("#InventoryArea" + i).numberbox('getValue');
            var InventoryTonWeight = $("#InventoryTonWeight" + i).numberbox('getValue');
            var WareHouseId = $("#WareHouseId" + i).val();
            var WareHouseName = $("#WareHouseName" + i).textbox('getValue');
            var EntryTime = $("#EntryTime" + i).datebox('getValue');
            var ProductionDate = $("#ProductionDate" + i).datebox('getValue');
            var ExpirationDate = $("#ExpirationDate" + i).datebox('getValue');
            var ProducingArea = $("#ProducingArea" + i).textbox('getValue');
            var Remark = $("#Remark" + i).textbox('getValue');
            var Processed = $("#sbProcessed" + i).switchbutton('options').checked;

            if (Number(OutNumber) > Number(InventoryNumber)) {
                isCheck = false;
            }

            var detail = {
                "Id": Id,
                "OutId": OutId,
                "GoodsNo": GoodsNo,
                "GoodsId": GoodsId,
                "GoodsSpecId": GoodsSpecId,
                "GoodsName": GoodsName,
                "GoodsSpecName": GoodsSpecName,
                "Weight": Weight,
                "OutNumber": OutNumber,
                "PlateNumber": PlateNumber,
                "Area": Area,
                "TonWeight": TonWeight,
                "InventoryNumber": InventoryNumber,
                "InventoryArea": InventoryArea,
                "InventoryTonWeight": InventoryTonWeight,
                "WareHouseId": WareHouseId,
                "WareHouseName": WareHouseName,
                "EntryTime": EntryTime,
                "ProductionDate": ProductionDate,
                "ExpirationDate": ExpirationDate,
                "ProducingArea": ProducingArea,
                "Remark": Remark,
                "Processed": Processed,
            };
            detailList.push(detail);
        });

        var costList = new Array();
        costdom.forEach(function (value, index) {
            var i = value;
            var Id = $("#CostsId" + i).val();
            var OutId = $("#OutId" + i).val();
            var CostId = $("#CostType" + i).combobox('getValue');
            var UnitPrice = $("#UnitPrice" + i).numberbox('getValue');
            var Unit = $("#ChargingUnit" + i).numberbox('getValue');
            var UnitName = $("#ChargingUnit" + i).combobox('getText');
            var number = $("#CNumber" + i).numberbox('getValue');
            var Amount = $("#Amount" + i).numberbox('getValue');

            var cost = {
                "Id": Id,
                "OutId": OutId,
                "CostId": CostId,
                "UnitPrice": UnitPrice,
                "Unit": Unit,
                "UnitName": UnitName,
                "Number": number,
                "Amount": Amount,
            };
            costList.push(cost);
        });

        var d = JSON.stringify({ WarehouseOut: data, Details: detailList, Costs: costList, AttachmentId: $("#hidFileId").val() });

        if (!isCheck) {
            Helper.Show("出库数量不能大于库存数量");
            return;
        }
        $.messager.progress({
            title: '请稍后',
            msg: '数据保存中...',
        });
        window.setTimeout(function () {
            $.ajax({
                url: '/GoodsOrder/EditLKWarehouseOut',
                type: "post",
                data: d,
                contentType: 'application/json; charset=utf-8',
                success: function (json) {
                    $.messager.progress('close');
                    Helper.Show(json.Msg);
                    if (json.Success) {
                        setTimeout(function () { window.location.href = "/GoodsOrder/LKWarehouseOutList"; }, 2000);
                    }
                }
            });
        }, 2000);
    }

    function reviewLKWarehouseOut() {
        $.messager.confirm('提示信息', '您确认要复核吗?', function (r) {
            if (!r) { return false; }
            $.post("/GoodsOrder/ReviewLKWarehouseOut", { id: $("#Id").val() }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    setTimeout(function () { window.location.href = "/GoodsOrder/LKWarehouseOutList"; }, 2000);
                }
            });
        });
    }

</script>
<link href="~/Content/css/custome.css" rel="stylesheet" />
<div title="编辑商品出库单" style="width:auto; height:auto; padding-left:5px; font-size:14px;  ">
    <div class="ftitle">
        @if (!Model.WarehouseOut.IsReview)
        {
            <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="editLKWarehouseOut()">保存</a>
            <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="reviewLKWarehouseOut()">复核</a>
        }
            <a href="javascript:" class="easyui-linkbutton" data-options="iconCls:'icon-print'" onclick="print()">打印</a>
            <a href="/GoodsOrder/LKWarehouseOutList" class="easyui-linkbutton" iconCls="icon-back" style="height:32px">返回</a>
        </div>
    <form id="fm" method="post" novalidate>
        <input type="hidden" id="Id" value="@Model.WarehouseOut.Id" />
        <div class="ftitle">基础信息</div>
        <div class="fitem1">
            <label>
                出库单编号:
            </label>
            <input class="easyui-textbox" id="BillNo" name="BillNo" value="@Model.WarehouseOut.BillNo" style="width: 173px; height: 30px;" readonly="readonly">
            <label>
                出库时间:
            </label>
            <input id="OutTime" name="OutTime" value="@Model.WarehouseOut.OutTime.ToString("yyyy-MM-dd")" class="easyui-datebox" style="width: 173px; height: 30px;" />
            <label>
                客户:
            </label>
            <select class="easyui-combobox" id="CustomerId" value="@Model.WarehouseOut.CustomerId" style="width: 173px; height: 30px;" data-options="editable: false,prompt:'客户'"></select>
            <label>
                客户名称:
            </label>
            <input class="easyui-textbox" id="CustomerName" name="CustomerName" value="@Model.WarehouseOut.CustomerName" style="width: 173px; height: 30px;" readonly="readonly">
        </div>
        <div class="fitem1">
            <label>
                车牌号:
            </label>
            <input class="easyui-textbox" id="CarNumber" name="CarNumber" value="@Model.WarehouseOut.CarNumber" style="width: 173px; height: 30px;">
            <label>
                总吨重:
            </label>
            <input id="TotalTon" value="@Model.WarehouseOut.TotalTon" class="easyui-numberbox" data-options="precision:'4',prompt:'总吨重'" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                总件数:
            </label>
            <input id="Total" value="@Model.WarehouseOut.Total" class="easyui-numberbox" data-options="prompt:'总件数'" style="width: 173px; height: 30px;" readonly="readonly" />
            <label>
                总金额:
            </label>
            <input id="Amount" name="Amount" value="@Model.WarehouseOut.Amount" class="easyui-numberbox" data-options="precision:'2',prompt:'总金额'" style="width: 80px; height: 30px;" readonly="readonly" />
            <label>
                按吨操作:
            </label>
            <input class="easyui-switchbutton" id="sbIsByTon" value="@Model.WarehouseOut.IsByTon" data-options="onText:'是',offText:'否'">
        </div>
        <div class="fitem1">
            <label>
                搬运工单号:
            </label>
            <input class="easyui-textbox" id="PorterNo" name="PorterNo" style="width: 173px; height: 30px;">
            <label>
                是否复核:
            </label>
            <input class="easyui-switchbutton" id="sbIsReview" value="@Model.WarehouseOut.IsReview" data-options="onText:'是',offText:'否'">
        </div>
        <div class="fitem1">
            <label>
                图片:
            </label>
            <input type="hidden" id="hidFileId" />
            <input id="filebox" class="easyui-filebox" name="file" data-options="buttonText:'选择文件',accept:'image/*',onChange:fileChange" /><a href="@Model.FilePath" target="_blank">@Model.FileName</a>
        </div>
        <div class="fitem1">
            <label>
                备注:
            </label>
            <textarea rows="4" cols="4" style="width: 400px; height: 90px; vertical-align: top" name="Remark" id="Remark" autocomplete="off" placeholder="200字以内">@Model.WarehouseOut.Remark</textarea>
        </div>

        <div id="Wl">
            <div id="tabs" class="easyui-tabs" fit="true" border="false" style="width:500px;height:300px; padding-top:5px;">
                <div title="商品明细">
                    <input id="DomNum" type="hidden" value="@(Model.Details.Count+1)" />
                    @{
                        int i = 1;
                    }
                    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom()">添加</a>
                    <table class="gridtable" id="detailgird">
                        <thead>
                            <tr>
                                <th width="120px">商品批号</th>
                                <th width="120px">商品名称</th>
                                <th width="120px">规格</th>
                                <th>件重</th>
                                <th>出库件数</th>
                                <th>板数</th>
                                <th>托盘数/面积</th>
                                <th>出库吨重</th>
                                <th>库存件数</th>
                                <th>库存托盘数/面积</th>
                                <th>库存吨重</th>
                                <th width="120px">仓位</th>
                                <th>入库时间</th>
                                <th>生产日期</th>
                                <th>保质日期</th>
                                <th>产地</th>
                                <th>备注</th>
                                <th>已处理</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model.Details)
                            {
                                <tr id="@i">
                                    <td>
                                        <input class="easyui-textbox" id="@("GoodsNo")@i" name="@("GoodsNo")@i" value="@item.GoodsNo" style="width: 120px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("DetailDomId")@i" value="@i" />
                                        <input type="hidden" id="@("DetailId")@i" value="@item.Id" />
                                        <input type="hidden" id="@("OutId")@i" value="@item.OutId" />
                                    </td>
                                    <td>
                                        <input class="easyui-textbox" id="@("GoodsName")@i" name="@("GoodsName")@i" value="@item.GoodsName" style="width: 120px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("GoodsId")@i" value="@item.GoodsId" />
                                    </td>
                                    <td>
                                        <input class="easyui-textbox" id="@("GoodsSpecName")@i" name="@("GoodsSpecName")@i" value="@item.GoodsSpecName" style="width: 120px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("GoodsSpecId")@i" value="@item.GoodsSpecId" />
                                    </td>
                                    <td><input id="@("Weight")@i" name="@("Weight")@i" value="@item.Weight" class="easyui-numberbox" data-options="precision:'4',prompt:'件重',onChange:calculateWeight" style="width: 80px; height: 30px;" readonly="readonly" /></td>
                                    <td><input id="@("OutNumber")@i" class="easyui-numberbox" value="@item.OutNumber" data-options="prompt:'出库件数',onChange:calculateWeight" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("PlateNumber")@i" class="easyui-numberbox" value="@item.PlateNumber" data-options="prompt:'板数'" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("Area")@i" name="@("Area")@i" value="@item.Area" class="easyui-numberbox" data-options="precision:'2',prompt:'托盘数/面积'" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("TonWeight")@i" name="@("TonWeight")@i" value="@item.TonWeight" class="easyui-numberbox" data-options="precision:'4',prompt:'出库吨重',onChange:calculateWeight" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("InventoryNumber")@i" class="easyui-numberbox" value="@item.InventoryNumber" data-options="prompt:'库存件数'" style="width: 80px; height: 30px;" readonly="readonly" /></td>
                                    <td><input id="@("InventoryArea")@i" name="@("InventoryArea")@i" value="@item.InventoryArea" class="easyui-numberbox" data-options="precision:'2',prompt:'库存托盘数/面积'" style="width: 80px; height: 30px;" readonly="readonly" /></td>
                                    <td><input id="@("InventoryTonWeight")@i" name="@("InventoryTonWeight")@i" value="@item.InventoryTonWeight" class="easyui-numberbox" data-options="precision:'4',prompt:'库存吨重'" style="width: 80px; height: 30px;" readonly="readonly" /></td>
                                    <td>
                                        <input class="easyui-textbox" id="@("WareHouseName")@i" name="@("WareHouseName")@i" value="@item.WareHouseName" style="width: 120px; height: 30px;" readonly="readonly">
                                        <input type="hidden" id="@("WareHouseId")@i" value="@item.WareHouseId" />
                                    </td>
                                    <td><input id="@("EntryTime")@i" name="@("EntryTime")@i" value="@item.EntryTime" class="easyui-datebox" style="width: 120px; height: 30px;" /></td>
                                    <td><input id="@("ProductionDate")@i" name="@("ProductionDate")@i" value="@item.ProductionDate.ToString("yyyy-MM-dd")" class="easyui-datebox" style="width: 120px; height: 30px;" /></td>
                                    <td><input id="@("ExpirationDate")@i" name="@("ExpirationDate")@i" value="@item.ExpirationDate.ToString("yyyy-MM-dd")" class="easyui-datebox" style="width: 120px; height: 30px;" /></td>
                                    <td><input class="easyui-textbox" id="@("ProducingArea")@i" name="@("ProducingArea")@i" value="@item.ProducingArea" style="width: 80px; height: 30px;" readonly="readonly"></td>
                                    <td><input class="easyui-textbox" id="@("Remark")@i" name="@("Remark")@i" value="@item.Remark" style="width: 80px; height: 30px;" readonly="readonly"></td>
                                    <td><input class="easyui-switchbutton" id="sb@("Processed")@i" value="@item.Processed" data-options="onText:'是',offText:'否'"></td>
                                    <td><a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" style=" width:80px;" onclick="delDom(@i)">删除</a></td>
                                </tr>
                                i++;
                            }
                        </thead>
                    </table>
                    @{
                        i = 1;
                    }
                    @foreach (var item in Model.Details)
                    {
                        <script type="text/javascript">
$(function () {
                            $('@("#sbProcessed")@i').switchbutton({ checked: @Html.Raw(item.Processed ? "true" : "false") });
});
                        </script>
                        i++;
                    }
                </div>
                <div title="其他费用">
                    <input id="CostDomNum" type="hidden" value="@(Model.Costs.Count+1)" />
                    @{
                        int ci = 1;
                    }
                    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDom2()">添加</a>
                    <table class="gridtable" id="costgird">
                        <thead>
                            <tr>
                                <th>费用类型</th>
                                <th>杂费单价</th>
                                <th>单位</th>
                                <th>计算数量</th>
                                <th>金额</th>
                                <th>操作</th>
                            </tr>
                            @foreach (var item in Model.Costs)
                            {
                                <tr id="@("CostTr")@ci">
                                    <td>
                                        <input id="@("CostType")@ci" class="easyui-combobox" value="@item.CostId" data-options="prompt:'费用类型',onChange:calculateAmount" style="width: 173px; height: 30px;" />
                                        <input type="hidden" id="@("CostTypeId")@ci" value="@item.CostId" />
                                        <input type="hidden" id="@("CostDomId")@ci" value="@ci" />
                                        <input type="hidden" id="@("CostsId")@ci" value="@item.Id" />
                                        <input type="hidden" id="@("OutId")@ci" value="@item.OutId" />
                                    </td>
                                    <td><input id="@("UnitPrice")@ci" name="@("UnitPrice")@ci" value="@item.UnitPrice" class="easyui-numberbox" data-options="precision:'2',prompt:'杂费单价',onChange:calculateAmount" style="width: 80px; height: 30px;" /></td>
                                    <td><input id="@("ChargingUnit")@ci" class="easyui-combobox" value="@item.Unit" data-options="prompt:'单位'" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("CNumber")@ci" class="easyui-numberbox" value="@item.Number" data-options="prompt:'计算数量',onChange:calculateAmount" style="width: 173px; height: 30px;" /></td>
                                    <td><input id="@("Amount")@ci" name="@("Amount")@ci" value="@item.Amount" class="easyui-numberbox" data-options="precision:'2',prompt:'金额'" style="width: 80px; height: 30px;" /></td>
                                    <td><a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" style=" width:80px;" onclick="delDom2(@ci)">删除</a></td>
                                </tr>
                                ci++;
                            }
                        </thead>
                    </table>
                    @{
                        ci = 1;
                    }
                    @foreach (var item in Model.Costs)
                    {
                        <script type="text/javascript">
$(function () {
    InitCostTypesCombogrid2(@ci);
    InitChargingUnitCombobox(@ci);
});
                        </script>
                        ci++;
                    }
                </div>
            </div>
        </div>
        <div class="fitem1">
            @{
                var modifyuser = Model.WarehouseOut.ModifyUserId == 0 ? Gx.Dal.Shared.UserContext.CurrentUser.EmpName : Model.WarehouseOut.ModifyUser;
                var modifytime = Model.WarehouseOut.ModifyTime.ToString("yyyy-MM-dd") == "1911-01-01" ? "" : Model.WarehouseOut.ModifyTime.ToString("yyyy-MM-dd");
            }
            <label>
                制单人:
            </label>
            <label>
                @Model.WarehouseOut.CreateUser
            </label>

            <label>
                制单日期:
            </label>
            <label>
                @Model.WarehouseOut.CreateTime.ToString("yyyy-MM-dd")
            </label>
            <label>
                修改人:
            </label>
            <label>
                @modifyuser
            </label>
            <label>
                修改日期:
            </label>
            <label>
                @modifytime
            </label>
        </div>
    </form>
</div>

<div id="dlg" class="easyui-dialog" title="商品引导出库" data-options="iconCls:'icon-save'"
     closed="true" style="width: 1050px; height: 500px; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
    <table id="dg" class="easyui-datagrid" style="width:100%; height: 380px;"
           url="/GoodsOrder/GetLKWarehouseEntryDetailsByCustomerId" toolbar="#tb" title="入库商品明细" rownumbers="true" pagination="true"
           pagelist="[15]" fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="GoodsNo" align="right" width="120px">
                    商品批号
                </th>
                <th field="GoodsId" align="right" width="80px" hidden="hidden">
                    商品id
                </th>
                <th field="GoodsSpecId" align="right" width="80px" hidden="hidden">
                    规格
                </th>
                <th field="WareHouseId" align="right" width="80px" hidden="hidden">
                    仓位
                </th>
                <th field="GoodsName" align="right" width="120px">
                    商品名称
                </th>
                <th field="GoodsSpecName" align="right" width="80px">
                    规格名称
                </th>
                <th field="WareHouseName" align="right" width="80px">
                    仓库名称
                </th>
                <th field="Weight" align="right" width="80px">
                    件重
                </th>
                <th field="OrginNumber" align="right" width="10%">
                    入库件数
                </th>
                <th field="Number" align="right" width="10%">
                    库存件数
                </th>
                <th field="Area" align="right" width="80px">
                    面积
                </th>
                <th field="AvNumber" align="right" width="80px">
                    每板件数
                </th>
                <th field="TonWeight" align="right" width="80px">
                    吨重
                </th>
                <th field="PlateNumber" align="right" width="80px">
                    板数
                </th>
                <th field="ProductionDate" align="right" width="80px">
                    生产日期
                </th>
                <th field="ExpirationDate" align="right" width="80px">
                    保质日期
                </th>
                <th field="ProducingArea" align="right" width="80px">
                    产地
                </th>
                <th field="Remark" align="right" width="80px">
                    备注
                </th>
            </tr>
        </thead>
    </table>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="selectEntryDetail()">选择</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>











